home *** CD-ROM | disk | FTP | other *** search
/ Champak 142 / Volume 142 Oct 17 2011 - Damaged.iso / Games / operation-graduates.swf / scripts / frame_41 / DoAction_17.as < prev    next >
Text File  |  2011-10-17  |  3KB  |  127 lines

  1. function createPowerupContainer()
  2. {
  3.    createEmptyMovieClip("powerupContainer",powerupDepth);
  4.    powerupCount = 0;
  5. }
  6. function spawnPowerup(xSpot, powType)
  7. {
  8.    var _loc1_ = powType;
  9.    var _loc2_ = true;
  10.    i = 0;
  11.    while(i < theHull.upgrades.length)
  12.    {
  13.       if(theHull.upgrades[i] == 0)
  14.       {
  15.          _loc2_ = false;
  16.       }
  17.       i++;
  18.    }
  19.    if(_loc2_)
  20.    {
  21.       spawn1UP(xSpot);
  22.    }
  23.    else
  24.    {
  25.       while(theHull.upgrades[_loc1_ - 1] > 0)
  26.       {
  27.          _loc1_ = _loc1_ + 1;
  28.          if(_loc1_ > 5)
  29.          {
  30.             _loc1_ = 1;
  31.          }
  32.       }
  33.       powerupCount++;
  34.       var _loc3_ = powerupContainer.attachMovie("powerup" + _loc1_,"powerup" + powerupCount,powerupCount);
  35.       _loc3_._y = (- _loc3_._height) / 2;
  36.       _loc3_._x = xSpot;
  37.       _loc3_.pType = _loc1_;
  38.       _loc3_.move = powerupMover;
  39.       _loc3_.hit = powerupHit;
  40.    }
  41. }
  42. function spawn1UP(xSpot)
  43. {
  44.    if(theHull.lives < 12)
  45.    {
  46.       powerupCount++;
  47.       var _loc1_ = powerupContainer.attachMovie("extraLife","powerup" + powerupCount,powerupCount);
  48.       _loc1_._y = (- _loc1_._height) / 2;
  49.       _loc1_._x = xSpot;
  50.       _loc1_.move = powerupMover;
  51.       _loc1_.hit = extralifeHit;
  52.    }
  53. }
  54. function powerupHit()
  55. {
  56.    var _loc2_ = this;
  57.    playSound("sound.powerup");
  58.    playSound("sound.ready." + _loc2_.pType);
  59.    doWhiteFlash();
  60.    var _loc1_ = 0;
  61.    i = 0;
  62.    while(i < 5)
  63.    {
  64.       if(theHull.upgrades[i] > 0)
  65.       {
  66.          theHull.upgrades[i] = 1;
  67.          _loc1_ = _loc1_ + 1;
  68.       }
  69.       i++;
  70.    }
  71.    theHull.upgrades[_loc2_.pType - 1] = 1;
  72.    theHull.attachMovie(theHull.upgrades[0] + "" + theHull.upgrades[1] + "" + theHull.upgrades[2] + "" + theHull.upgrades[3] + "" + theHull.upgrades[4],"ship",0);
  73.    addScore(100);
  74.    _loc2_.removeMovieClip();
  75. }
  76. function extralifeHit()
  77. {
  78.    doWhiteFlash();
  79.    addLife();
  80.    playSound("sound.1up");
  81.    this.removeMovieClip();
  82. }
  83. function powerupMover()
  84. {
  85.    var _loc1_ = this;
  86.    _loc1_._y += 3;
  87.    if(_loc1_._y - _loc1_._height / 2 > Stage.height)
  88.    {
  89.       _loc1_.removeMovieClip();
  90.    }
  91. }
  92. function powerupExecute()
  93. {
  94.    for(tp in powerupContainer)
  95.    {
  96.       p = powerupContainer[tp];
  97.       p.move();
  98.       if(p.hitTest(theHull) && theHull.alive)
  99.       {
  100.          p.hit();
  101.       }
  102.    }
  103. }
  104. function bigFatCheater()
  105. {
  106.    var _loc2_ = true;
  107.    var _loc1_ = new Array();
  108.    i = 0;
  109.    while(i < theHull.upgrades.length)
  110.    {
  111.       if(theHull.upgrades[i] == 0)
  112.       {
  113.          _loc2_ = false;
  114.          _loc1_.push(i);
  115.       }
  116.       i++;
  117.    }
  118.    if(!_loc2_ && theHull.alive)
  119.    {
  120.       playSound("sound.cheat");
  121.       doWhiteFlash();
  122.       var _loc3_ = _loc1_[random(_loc1_.length)];
  123.       theHull.upgrades[_loc3_] = 1;
  124.       theHull.attachMovie(theHull.upgrades[0] + "" + theHull.upgrades[1] + "" + theHull.upgrades[2] + "" + theHull.upgrades[3] + "" + theHull.upgrades[4],"ship",0);
  125.    }
  126. }
  127.